import { Link } from '@brillout/docpress'
import { CommunityNote } from '../../components'

<CommunityNote url="https://www.docker.com/" />

From the server's perspective, a Vike app is just a Node.js server, which means you can use any Node.js container image to run your Vike app.

If you want to use Docker also for development, then you shouldn't set `host` to `false` and you may need to configure Docker for HMR, see <Link href="#development" />.

If you build your app inside your Docker container and run into out-of-memory errors, then see <Link href="#increase-memory" />.


## Development

### `host`

If you want to use Docker also for development, then [Vite's `server.host` setting](https://vite.dev/config/server-options.html#server-host) should be truthy so that your app can be accessed from outside your Docker container, such as from the browser.

```js
// vite.config.js

export default {
  server: {
    host: true
  }
}
```

> Vike sets the default value of `host` to `true` if it detects a Docker or Podman container environment.

### HMR

If [HMR](https://vite.dev/guide/why.html#:~:text=some%20bundlers%20support-,Hot%20Module%20Replacement%20(HMR),-%3A%20allowing%20a%20module) doesn't work, then make sure you configure Docker for [Vite's HMR websocket connection](https://vite.dev/config/server-options.html#server-hmr).

If you run Docker with a WSL2 backend, then have a look at <Link href="/wsl" /> for how to enable HMR.


## Increase memory

If you build your app inside your Docker container, you may stumble upon out-of-memory errors.

Check whether your Docker container has enough memory, and you may also need to set [Node.js' `--max-old-space-size`](https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes).

```json
// package.json
{
  "scripts": {
    "build": "vite build" // [!code --]
    "// Increase Node.js memory size to 3GB": "", // [!code ++]
    "build": "NODE_OPTIONS=--max-old-space-size=3072 npm run build:vite", // [!code ++]
    "build:vite": "vite build" // [!code ++]
  }
}
```
